//
// Created by A4-28 on 2020/10/22.
//
#pragma once
#include "glm/glm.hpp"
#include "glm/gtx/quaternion.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtx/euler_angles.hpp"
#include "quaternion.h"

namespace WF {
    enum Projection {
        Perspective,
        Orthographic
    };

    struct Camera {
        Projection projection;
        float FOV;
        glm::vec2 ClipPanel;
        glm::vec4 viewRect;
        glm::vec3 BackGroundColor;
        float Depth;
        bool OcclusionCulling;

        glm::mat4 ProjectMatrix;
        glm::mat4 ViewMatrix;

        void SetProjectMatrix(glm::vec2 screenSize) {
            if (projection == Perspective) {
                ProjectMatrix = glm::perspective(glm::radians(FOV), screenSize.x / screenSize.y, ClipPanel.x, ClipPanel.y);
            } else {
                float aspectRatio = screenSize.x / screenSize.y;
                ProjectMatrix = glm::ortho(-aspectRatio * FOV, aspectRatio * FOV, -FOV, FOV, ClipPanel.x, ClipPanel.y);
            }
        }
    };
}


